<?php 
/*
 module:		resume_work
 create_time:	2024-03-11 13:47:44
 author:		
 contact:		
*/

namespace app\api\controller;

use app\api\service\ResumeworkService;
use app\api\model\Resumework as ResumeworkModel;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\Log;

class Resumework extends Common {


	/**
	* @api {post} /Resumework/delete 03、删除
	*/
	function delete(){
		$idx =  $this->request->post('id', '', 'serach_in');
		if(empty($idx)){
			throw new ValidateException('参数错误');
		}
		$data['id'] = explode(',',$idx);
		try{
			ResumeworkModel::destroy($data,true);
		}catch(\Exception $e){
			abort(config('my.error_log_code'),$e->getMessage());
		}
		return $this->ajaxReturn($this->successCode,'操作成功');
	}

    /*start*/
    /**
     * @api {post} /Resumework/add 01、添加
     */
    function add(){
        $postField = 'pid,startyear,startmonth,endyear,endmonth,companyname,jobs,achievements,todate';
        $data = $this->request->only(explode(',',$postField),'post',null);
        $data["uid"] = $this->request->uid;
        $res = ResumeworkService::add($data);
        return $this->ajaxReturn($this->successCode,'操作成功',$res);
    }

    /**
     * @api {post} /Resumework/update 02、修改
     */
    function update(){
        $postField = 'id,startyear,startmonth,endyear,endmonth,companyname,jobs,achievements,todate';
        $data = $this->request->only(explode(',',$postField),'post',null);
        if(empty($data['id'])){
            throw new ValidateException('参数错误');
        }
        $where['id'] = $data['id'];
        $res = ResumeworkService::update($where,$data);
        return $this->ajaxReturn($this->successCode,'操作成功');
    }
    /*end*/

}

